<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of v_lpcar2fm</title>
  <meta name="keywords" content="v_lpcar2fm">
  <meta name="description" content="V_LPCAR2RF Convert autoregressive coefficients to formant freq+amp+bw [N,F,A,B]=(AR,T)">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">v_mfiles</a> &gt; v_lpcar2fm.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for v_mfiles&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>v_lpcar2fm
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>V_LPCAR2RF Convert autoregressive coefficients to formant freq+amp+bw [N,F,A,B]=(AR,T)</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [n,f,a,b]=v_lpcar2fm(ar,t) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment">V_LPCAR2RF Convert autoregressive coefficients to formant freq+amp+bw [N,F,A,B]=(AR,T)

 Input:   ar(:,p+1)  Autoregressive coefficients
          t          Threshold (see below)
 Output:  n          Number of formants found
          f          Formant frequencies in normalized Hz (in increasing order)
          a          Formant amplitudes
          b          Formant bandwidths in normalized Hz

 The number of columns in the output arrays f, a and b is max(n); surplus positions
 in any given row have f=b=0.

 In determining formants, poles are ignored if any of the following hold:
        (a) they are on the real axis
        (b) they have bandwidth &gt; t*frequency (if t&gt;0)
        (c) they have bandwidth &gt; -t (if t&lt;=0)</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="v_lpcar2zz.html" class="code" title="function zz=v_lpcar2zz(ar)">v_lpcar2zz</a>	V_LPCAR2ZZ Convert ar filter to z-plane poles ZZ=(AR)</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [n,f,a,b]=v_lpcar2fm(ar,t)</a>
0002 <span class="comment">%V_LPCAR2RF Convert autoregressive coefficients to formant freq+amp+bw [N,F,A,B]=(AR,T)</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% Input:   ar(:,p+1)  Autoregressive coefficients</span>
0005 <span class="comment">%          t          Threshold (see below)</span>
0006 <span class="comment">% Output:  n          Number of formants found</span>
0007 <span class="comment">%          f          Formant frequencies in normalized Hz (in increasing order)</span>
0008 <span class="comment">%          a          Formant amplitudes</span>
0009 <span class="comment">%          b          Formant bandwidths in normalized Hz</span>
0010 <span class="comment">%</span>
0011 <span class="comment">% The number of columns in the output arrays f, a and b is max(n); surplus positions</span>
0012 <span class="comment">% in any given row have f=b=0.</span>
0013 <span class="comment">%</span>
0014 <span class="comment">% In determining formants, poles are ignored if any of the following hold:</span>
0015 <span class="comment">%        (a) they are on the real axis</span>
0016 <span class="comment">%        (b) they have bandwidth &gt; t*frequency (if t&gt;0)</span>
0017 <span class="comment">%        (c) they have bandwidth &gt; -t (if t&lt;=0)</span>
0018 
0019 <span class="comment">%      Copyright (C) Mike Brookes 1997</span>
0020 <span class="comment">%      Version: $Id: v_lpcar2fm.m 10865 2018-09-21 17:22:45Z dmb $</span>
0021 <span class="comment">%</span>
0022 <span class="comment">%   VOICEBOX is a MATLAB toolbox for speech processing.</span>
0023 <span class="comment">%   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html</span>
0024 <span class="comment">%</span>
0025 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
0026 <span class="comment">%   This program is free software; you can redistribute it and/or modify</span>
0027 <span class="comment">%   it under the terms of the GNU General Public License as published by</span>
0028 <span class="comment">%   the Free Software Foundation; either version 2 of the License, or</span>
0029 <span class="comment">%   (at your option) any later version.</span>
0030 <span class="comment">%</span>
0031 <span class="comment">%   This program is distributed in the hope that it will be useful,</span>
0032 <span class="comment">%   but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
0033 <span class="comment">%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
0034 <span class="comment">%   GNU General Public License for more details.</span>
0035 <span class="comment">%</span>
0036 <span class="comment">%   You can obtain a copy of the GNU General Public License from</span>
0037 <span class="comment">%   http://www.gnu.org/copyleft/gpl.html or by writing to</span>
0038 <span class="comment">%   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.</span>
0039 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
0040 
0041 [nf,p1]=size(ar);
0042 p=p1-1;
0043 d=(1:nf)';
0044 zz=<a href="v_lpcar2zz.html" class="code" title="function zz=v_lpcar2zz(ar)">v_lpcar2zz</a>(ar);
0045 ig=imag(zz)&lt;=0;
0046 n=p1-1-sum(ig,2);
0047 mn=max(n);
0048 
0049 <span class="comment">% remove redundant columns</span>
0050 
0051 <span class="keyword">if</span> mn&lt;p
0052    [ig,ix]=sort(ig,2);
0053    zz=reshape(zz(d(:,ones(1,mn))+nf*(ix(:,1:mn)-1)),nf,mn);
0054    ig(:,mn+1:end)=[];
0055 <span class="keyword">end</span>
0056 
0057 zz(ig)=1;      <span class="comment">% to prevent infinities</span>
0058 f=angle(zz)*0.5/pi;
0059 b=-log(abs(zz))/pi;
0060 <span class="keyword">if</span> nargin &gt; 1
0061    <span class="keyword">if</span> t&gt;0
0062       ig=ig | b&gt;t*f;
0063    <span class="keyword">else</span>
0064       ig=ig | b+t&gt;0;
0065    <span class="keyword">end</span>
0066 <span class="keyword">end</span>
0067 f(ig)=0;
0068 b(ig)=0;
0069 n=mn-sum(ig,2);
0070 m=max(n);
0071 
0072 <span class="comment">% remove redundant columns</span>
0073 
0074 [igf,ix]=sort(ig+f,2);
0075 dd=d(:,ones(1,m))+nf*(ix(:,1:m)-1);
0076 zz=reshape(zz(dd),nf,m);
0077 f=reshape(f(dd),nf,m);
0078 b=reshape(b(dd),nf,m);
0079 ig=reshape(ig(dd),nf,m);
0080 
0081 <span class="comment">% now calculate gain</span>
0082 ap=permute(ar,[1 3 2]);
0083 pw=permute(-2*pi*1i*(0:p),[1 3 2]);
0084 a=abs(sum(ap(:,ones(1,m),:).*exp(pw(ones(1,nf),ones(1,m),:).*f(:,:,ones(1,p1))),3)).^(-1);</pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>